<template>
  <nav class="navBar">
    <div>
      <div class="nav_left">
        <div>{{ dateYear }}</div>
        <div>{{ dateWeek }}</div>
      </div>
      <dv-decoration-4
        :color="['#2063b5', '#2063b5']"
        :reverse="true"
        :dur="1"
        style="width: 2.5rem; height: 0.05rem"
      />
    </div>
    <div class="nav_center">
      <div>{{ title ? "特种设备理论考试排队" : "特种设备考试实操排队" }}</div>
      <dv-decoration-5
        :color="['#2063b5', '#bedbfd']"
        :dur="1"
        style="width: 8rem; height: 0.31rem; margin: 0 auto"
      />
    </div>
    <div class="nav_right">
      <div class="timer">{{ dateDay }}</div>
      <dv-decoration-4
        :color="['#2063b5', '#2063b5']"
        :reverse="true"
        :dur="1"
        style="width: 2.5rem; height: 0.05rem"
      />
    </div>
  </nav>
</template>

<script>
import { formatTime } from "../untils/timer.js"; //日期格式转换
export default {
  data() {
    return {
      //时分秒
      dateDay: null,
      //年月日
      dateYear: null,
      //周几
      dateWeek: null,
      //周几
      weekday: [
        "星期日",
        "星期一",
        "星期二",
        "星期三",
        "星期四",
        "星期五",
        "星期六",
      ],
    };
  },
  props: {
    title: Boolean,
  },
  mounted() {
    //获取实时时间
    this.timeFn();
  },
  methods: {
    //右上角当前日期时间显示：每一秒更新一次最新时间
    timeFn() {
      this.timing = setInterval(() => {
        //获取当前时分秒
        this.dateDay = formatTime(new Date(), "HH: mm: ss");
        //获取当前年月日
        this.dateYear = formatTime(new Date(), "yyyy-MM-dd");
        //获取当前周几
        this.dateWeek = this.weekday[new Date().getDay()];
      }, 1000);
    },
  },
};
</script>
<style lang="scss" scoped>
.navBar {
  // width: 100vw;
  height: 0.8rem;
  color: aliceblue;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.4rem;
  .nav_left {
    display: flex;
    font-size: 0.24rem;
    color: #45a2ff;
    margin-bottom: 0.24rem;
    & > div:nth-of-type(1) {
      margin-right: 0.4rem;
    }
  }
  .nav_center {
    font-size: 0.36rem;
    color: #ffffff;
    font-weight: bold;
    & > div {
      margin-top: 0.2rem;
    }
  }
  .nav_right {
    font-size: 0.24rem;
    color: #ffffff;
    .timer {
      margin-bottom: 0.24rem;
    }
  }
}
</style>